﻿using System;

namespace Nature.Toolkit.GEqu
{
    public static partial class Extensions
    {
        public static void HP(this IChemicalEquilibriumCalculator calculator, ref Temperature temperature, Pressure pressure, double[] x)
        {
            double t = temperature.ToDouble();
            double p = pressure.ToDouble();
            calculator.HP(ref t, p, x);
            temperature = new Temperature(t, temperature.Units);
        }

        public static void UV(this IChemicalEquilibriumCalculator calculator, ref Temperature temperature, ref Pressure pressure, double[] x)
        {
            double t = temperature.ToDouble();
            double p = pressure.ToDouble();
            calculator.UV(ref t, ref p, x);
            temperature = new Temperature(t, temperature.Units);
            pressure = new Pressure(p, pressure.Units);
        }

        public static void TV(this IChemicalEquilibriumCalculator calculator, Temperature temperature, ref Pressure pressure, double[] x)
        {
            double t = temperature.ToDouble();
            double p = pressure.ToDouble();
            calculator.TV(t, ref p, x);
            pressure = (new Pressure(p)).Convert(pressure.Units);
        }

    }               
}